package com.ruoyi.StarStudio.Controller;

import com.ruoyi.StarStudio.Domain.*;
import com.ruoyi.StarStudio.Service.MainzoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 园区信息接口
 */
@RestController
@RequestMapping("/mainzone")
public class MainZoneController {

    @Autowired
    private MainzoneService mainzoneService;

    /**
     * 获取园区（乌梅园）信息
     * @return
     */
    @GetMapping
    public Result get(){
        MainZone mainzone = null;
        try{
            mainzone = mainzoneService.get();
        }catch (Exception e){
            e.printStackTrace();
            return new Result(HttpStatusCode.ERROR, MessageConstant.MAIN_ZONE_QUERY_FAIL);
        }
        return new Result(HttpStatusCode.SUCCESS, MessageConstant.MAIN_ZONE_QUERY_SUCCESS, mainzone);
    }

    /**
     * 新增园区信息（可能用不到）
     * @param mainzone
     * @return
     */
//    @PostMapping
//    public Result add(@RequestBody MainZone mainzone) {
//        try {
//            mainzoneService.add(mainzone);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return new Result(HttpStatusCode.ERROR, MessageConstant.MAIN_ZONE_ADD_FAIL);
//        }
//        return new Result(HttpStatusCode.SUCCESS, MessageConstant.MAIN_ZONE_ADD_SUCCESS);
//    }

    /**
     * 修改园区信息
     * @param mainzone
     * @return
     */
    @PutMapping
    public Result update(@RequestBody MainZone mainzone){
        try {
            mainzoneService.update(mainzone);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(HttpStatusCode.ERROR, MessageConstant.MAIN_ZONE_UPDATE_FAIL);
        }
        return new Result(HttpStatusCode.SUCCESS, MessageConstant.MAIN_ZONE_UPDATE_SUCCESS);
    }

}
